package cn.gov.pbc.gd.credit.vo.center.query;

import java.io.Serializable;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.Date;
import java.util.Map;

import com.liu.tools.DateUtil;
import com.liu.tools.StrUtil;

/**
 * @author liuxingmi
 * @datetime 2017年6月6日 下午9:29:03
 * @desc 申请表查询请求
 */
public class ReqCCApplyTblVo implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -1578332276567318071L;

	//branchquery/newdissent/creditReport/yy_apply_print2.jsp?
	//user=������&ctype=���֤&idno=412822198212021417&relname=&reltel=&
	//dissentid=201706024401240400050_c5d7b54d717ec68e0e466fbc7a7adffb&querydate=2017-06-02%2009:03:02
	//&querytype=������ϸ��&relcertno=&relcerttype= 
	

	/**
	 * 查询类型名称(个人明细版，个人简单版)
	 */
	private String querytype;
	
	/**
	 * 用户姓名
	 */
	private String user;
	
	/**
	 * 传证件类型名称
	 */
	private String ctype;
	
	/**
	 * 证件号码
	 */
	private String idno;
	
	/**
	 * 代理人联系方式
	 */
	private String reltel;
	
	/**
	 * 代理人姓名
	 */
	private String relname;
	
	/**
	 * 代理人证件类型
	 */
	private String relcerttype;
	
	/**
	 * 代理人证件号码
	 */
	private String relcertno;
	
	/**
	 * 申请编号
	 */
	private String dissentid;
	
	private String querydate;

	private Map<String, String> cookies;
	
	/**
	 * 操作员签名
	 */
	private String opSignName;

	private String note;

	public String getQuerytype() {
		return querytype;
	}

	public void setQuerytype(String querytype) {
		this.querytype = querytype;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getCtype() {
		return ctype;
	}

	public void setCtype(String ctype) {
		this.ctype = ctype;
	}

	public String getIdno() {
		return idno;
	}

	public void setIdno(String idno) {
		this.idno = idno;
	}

	public String getReltel() {
		return reltel;
	}

	public void setReltel(String reltel) {
		this.reltel = reltel;
	}

	public String getRelname() {
		return relname;
	}

	public void setRelname(String relname) {
		this.relname = relname;
	}

	public String getRelcerttype() {
		return relcerttype;
	}

	public void setRelcerttype(String relcerttype) {
		this.relcerttype = relcerttype;
	}

	public String getRelcertno() {
		return relcertno;
	}

	public void setRelcertno(String relcertno) {
		this.relcertno = relcertno;
	}

	public String getDissentid() {
		return dissentid;
	}

	public void setDissentid(String dissentid) {
		this.dissentid = dissentid;
	}

	public Map<String, String> getCookies() {
		return cookies;
	}

	public void setCookies(Map<String, String> cookies) {
		this.cookies = cookies;
	}

	public String getQuerydate() {
		return querydate;
	}

	public void setQuerydate(String querydate) {
		this.querydate = querydate;
	}

	public String getOpSignName() {
		return opSignName;
	}

	public void setOpSignName(String opSignName) {
		this.opSignName = opSignName;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public String toParams() {
		//querydate=2017-06-02%2009:03:02		
		try {

			StringBuilder builder = new StringBuilder();
			builder.append("querytype=");
			builder.append(StrUtil.isNull(querytype) ? "" : URLEncoder.encode(querytype, "GBK"));
			builder.append("&user=");
			builder.append(StrUtil.isNull(user) ? "" : URLEncoder.encode(user, "GBK"));
			builder.append("&ctype=");
			builder.append(StrUtil.isNull(ctype) ? "" : URLEncoder.encode(ctype, "GBK"));
			builder.append("&idno=");
			builder.append(StrUtil.isNull(idno) ? "" : URLEncoder.encode(idno,"GBK"));
			builder.append("&reltel=");
			builder.append(reltel);
			builder.append("&relname=");
			builder.append(StrUtil.isNull(relname) ? "" : URLEncoder.encode(relname, "GBK"));
			builder.append("&relcerttype=");
			builder.append(StrUtil.isNull(relcerttype) ? "" : URLEncoder.encode(relcerttype, "GBK"));
			builder.append("&relcertno=");
			builder.append(StrUtil.isNull(relcertno) ? "" : URLEncoder.encode(relcertno,"GBK"));
			builder.append("&dissentid=");
			builder.append(dissentid);
			builder.append("&querydate=");
			builder.append(DateUtil.format(new Date(), DateUtil.FORMAT_TIME));
			return builder.toString().replaceAll("null", "");

		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}
	
	public String toCodeStr(String encode) {
		//querydate=2017-06-02%2009:03:02		
		try {

			if(StrUtil.isNotNull(idno)){
				idno = URLEncoder.encode(idno, encode);
			}
			if(StrUtil.isNotNull(relcertno)){
				relcertno = URLEncoder.encode(relcertno, encode);
			}

			if(StrUtil.isNotNull(user)){
				user = URLEncoder.encode(user, "UTF-8");
			}
			
		} catch (Exception e) {
			
		}
		return ("querytype=" + querytype + "&user=" + user + "&ctype=" + ctype + "&idno=" + idno
				+ "&reltel=" + reltel + "&relname=" + relname + "&relcerttype=" + relcerttype + "&relcertno="
				+ relcertno + "&dissentid=" + dissentid + "&querydate=" + DateUtil.format(new Date(), DateUtil.FORMAT_TIME)).replaceAll("null", "");
	}
	
	public static void main(String[] args) throws Exception {
		
		String str = "%E5%85%AC%E7%8E%B0%E5%BD%B9%E5%AD%97%E7%AC%AC0022507%E5%8F%B7";
       String deStr = URLDecoder.decode(str,"UTF-8");
		
		System.err.println(deStr);
		
		System.err.println(str);
		String enStr = URLEncoder.encode("公现役字第0022507号", "GBK");
		System.err.println(enStr);
		
		 deStr = URLDecoder.decode(enStr,"GBK");
		
		System.err.println(deStr);
	}
}
